import math
import numpy as np
import pickle
from scipy import interpolate
import matplotlib as mpl
import matplotlib.pyplot as plt


spectral_dict=pickle.load(open("spectral_template.pickle", "rb"))
#vlsr=4.3
#spectral_dict[key]['freq_axis']=spectral_dict[key]['freq_axis']+vlsr/3.0e5*np.median(spectral_dict[key]['freq_axis'])
outfile=open('CH3OH_text_spectral_template.txt','w')
for i in range(len(spectral_dict['freq_axis'])):
      line='{} {}\n'.format(spectral_dict['freq_axis'][i]/1.0e6,spectral_dict['spectrum'][i])
      outfile.writelines(line)
outfile.close()

spectral_dict=pickle.load(open("spectral_template_lime.pickle", "rb"))
#vlsr=4.3
#spectral_dict[key]['freq_axis']=spectral_dict[key]['freq_axis']+vlsr/3.0e5*np.median(spectral_dict[key]['freq_axis'])
outfile=open('H218O_text_spectral_template.txt','w')
for i in range(len(spectral_dict['freq_axis'])):
      line='{} {}\n'.format(spectral_dict['freq_axis'][i]/1.0e6,spectral_dict['spectrum'][i])
      outfile.writelines(line)
outfile.close()


